package com.jackstraw.jack_base.mq.rocketmq.producer.listener.impl;

import com.jackstraw.jack_base.mq.rocketmq.bean.listener.ProducerTxService;
import com.jackstraw.jack_base.mq.rocketmq.bean.TrListenerEntity;
import com.jackstraw.jack_base.mq.rocketmq.bean.enums.TransactionStateEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class Default2ProducerTxServiceImpl implements ProducerTxService {

    @Override
    public TransactionStateEnum executeLocalTransaction(TrListenerEntity trListenerEntity) {
        log.info("Default2ProducerTxServiceImpl#executeLocalTransaction::TrListenerEntity[{}]", trListenerEntity);
        trListenerEntity.setTransactionStateEnum(TransactionStateEnum.COMMIT);
        return trListenerEntity.getTransactionStateEnum();
    }

    @Override
    public TransactionStateEnum checkLocalTransaction(TrListenerEntity trListenerEntity) {
        log.info("Default2ProducerTxServiceImpl#checkLocalTransaction::TrListenerEntity[{}]", trListenerEntity);
        trListenerEntity.setTransactionStateEnum(TransactionStateEnum.COMMIT);
        return trListenerEntity.getTransactionStateEnum();
    }
}
